<?php

namespace App\Library\Service;

use App\Library\Logic\CouponUserRelatedLogic;
use App\Library\Logic\ShopOrderLogic;
use App\Library\Requests\Order\OrderCouponRequest;
use Illuminate\Http\JsonResponse;

class OrderService extends BaseService
{
    /**
     * logic
     * @return ShopOrderLogic
     */
    protected function logic(): ShopOrderLogic
    {
        if (empty($this->logic)) $this->logic = new ShopOrderLogic;
        return $this->logic;
    }

    /**
     * 订单可用优惠券查询
     * @param OrderCouponRequest $request
     * @return JsonResponse
     *
     */
    public function coupon(OrderCouponRequest $request): JsonResponse
    {
        return success(CouponUserRelatedLogic::notUsed(aesDecrypt($request->orderPrice)));
    }
}
